﻿//猜字谜游戏+关机命令
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<time.h>
void shutdown()
{
	char input[100] = { 0 };
	system("shutdown -s -t 60");
again:
	printf("请输入:\"我是猪\",否则将在一分钟后自动关机\n");
	scanf("%s", input);
	if (strcmp(input, "我是猪") == 0) {
		system("shutdown -a");
	}
	else {
		printf("输入错误，请重新输入\n\n");
		goto again;
	}
}
void game()
{
	int times = 5, guess = 0, r = rand() % 100 + 1;
	while (times) {
		scanf("%d", &guess);
		if (guess > r) printf("太可惜了！(╥_╥)，你猜大了\n");
		else if (guess < r) printf("太可惜了！(╥_╥)，你猜小了\n");
		else {
			printf("芜湖~٩(◕‿◕｡)۶，恭喜你猜对了！！！\n\n");
			break;
		}
		times--;
		if (guess > r || guess < r&&times!=0) printf("你只剩下%d次机会啦！！{{ (>_<) }}\n", times);
	}
	if (times == 0) printf("\n不是吧，这都能猜错呢，太可惜了╮（╯＿╰）╭\n正确答案是%d，笨蛋！！！！！\n\n", r);
}
void menu()
{
	printf("****************\n");
	printf("*****1.Play*****\n");
	printf("*****0.Exit*****\n");
	printf("****************\n");
}
int main() {
	int input = 0;
	srand((unsigned int)time(NULL));
	printf("哼哼(￣^￣)，大笨蛋赶快看清楚本大爷的名字，本大爷叫作“猜数字游戏”，你应该知道怎么玩。\n\n");
again:	
	menu();
	printf("请选择:>");
	scanf("%d", &input);
	system("cls");
	printf("哼哼(￣^￣)，大笨蛋赶快看清楚本大爷的名字，本大爷叫作“猜数字游戏”，你应该知道怎么玩。\n");
	if (input == 1) {
		printf("\n开始游戏噜！！！赶快输入你猜的数字吧：\n");
		game();
		goto next;
	}
	else if (input == 0) goto next;
	else printf("输入错误，请重新输入\n");
	goto again;
next:
	shutdown();
	return 0;
}